/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package br.com.appleboxstore.models;

//import br.com.appleboxstore.controls.ClienteJpaController;
import br.com.appleboxstore.entities.Cliente;
import java.util.ArrayList;
import java.util.List;
import javax.swing.table.AbstractTableModel;

/**
 *
 * @author alexander
 */
public class JTableClienteModel extends AbstractTableModel {

    private static JTableClienteModel jTableClienteModel = new JTableClienteModel();

    public static JTableClienteModel getInstance() {
        return jTableClienteModel;
    }

    private JTableClienteModel() {
    }
    private List<Cliente> list = new ArrayList<>();

    public void updateList() {
//        list = new ClienteJpaController().findClienteEntities();
        fireTableDataChanged();
    }

    @Override
    public String getColumnName(int column) {
        switch (column) {
            case 0:
                return "Cód";
            case 1:
                return "Nome";
            case 2:
                return "Telefones";
            case 3:
                return "E-Mail";
            case 4:
                return "Observações";
            default:
                return null;
        }
    }

    @Override
    public int getRowCount() {
        return list.size();
    }

    @Override
    public int getColumnCount() {
        return 5;
    }

    @Override
    public Object getValueAt(int rowIndex, int columnIndex) {

        Cliente c = list.get(rowIndex);
        switch (columnIndex) {
            case 0:
                return c.getId();
            case 1:
                return c.getNome();
            case 2:
                return c.getTelefone1() + " / " + c.getTelefone2();
            case 3:
                return c.getEmail();
            case 4:
                return c.getObservacao();
            default:
                return null;
        }
    }
}
